Skip to content

fix(auto): honor merge_length_s passed to generate() - #3841

Merged
LauraGPT merged 1 commit into
modelscope:mainfrom
MohammadHijjawi97:fix/merge-length-s-per-call
Nov 5, 2026
Merged

LauraGPT merged 1 commit into
modelscope:mainfrom
MohammadHijjawi97:fix/merge-length-s-per-call

Conversation

@MohammadHijjawi97

Copy link
Copy Markdown
Contributor

Summary

With merge_vad=True, AutoModel.inference_with_vad read merge_length_s from the construction kwargs before the per-call options were merged in. A value passed to generate() was therefore ignored, and the construction value or the 15 s default was used instead. The SenseVoice README and examples/industrial_data_pretraining/sense_voice/demo.py both pass merge_length_s to generate(), so the documented usage had no effect for any value other than 15.

The merge step now uses the per-call value first, then the construction value, then the 15 s default. The merge_length_s row in docs/python_api.md / docs/python_api_zh.md no longer tells users to set it at construction.

Reproduction (VAD segments [[0, 4000], [5000, 9000], [10000, 14000]], generate(..., merge_vad=True, merge_length_s=10)):

  • Before: segments sent to ASR [[0, 14000]] (15 s default used)
  • After: [[0, 9000], [9000, 14000]]

Type of change

  • Bug fix
  • Documentation
  • Example or demo
  • Runtime or deployment
  • Benchmark or evaluation
  • Model/training change

Validation

  • python -m compileall funasr examples tests
  • Docs or links checked (tests/test_python_api_docs_contract.py)
  • Runtime/deployment command tested

New tests/test_merge_vad_length.py (CPU only, mocked models, no downloads): the two per-call cases fail on main and pass with this change; default and construction-time behavior is unchanged. tests/test_punc_model_none.py and tests/test_python_api_docs_contract.py pass.

User impact

Users following the SenseVoice examples with merge_vad=True can now control the merged segment length per call, as the README describes.

Notes for reviewers

Construction-time merge_length_s keeps working; a per-call value now takes precedence, consistent with how other generate() options are applied.

With merge_vad=True, inference_with_vad read merge_length_s from the
construction kwargs before the call options were merged in, so a value
passed to generate() (as in the SenseVoice README and demo) was silently
ignored and the construction value or the 15 s default was used instead.

Read the per-call value first and fall back to the construction value,
then the 15 s default. Update the Python API docs accordingly.

@LauraGPT LauraGPT left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed all four changed files at 099c2f4404be97c28ce20aa980afd8295d8dab37. Reading the per-call option before VAD merging fixes the ignored override while preserving the construction/default fallback and disabled-merge behavior. Both language references match the implementation.

Validation on the current-main candidate tree 175297234949cfbbba44e5b377f06b7d80c3b5c3:

  • Baseline reproduced the two submitted override failures; all 36 selected CPU regression/documentation tests passed with the change.
  • 32 real L20Z FP32 integration cases through AutoModel.generate, configuration reset, audio slicing and batched inference: baseline failed 8, candidate passed 32/32. Construction defaults/10s, repeated per-call 10s/default/15s/disabled, 1/2 inputs and 1s/300s batch budgets were covered. Each phase recorded 1,072 CUDA events and per-case raw results.
  • The GPU backends are explicit analytic torch fixtures with a zero scalar parameter, not pretrained ASR/VAD weights. This establishes wrapper/CUDA integration behavior, not ASR quality, Windows/NPU support or a full-suite result. No models were downloaded.
  • Exact-head hosted CI logs and NumPy 1.26.4/2.4.0 artifacts were inspected. Those existing workflows do not run the new four-case regression; its passing result above is local, not attributed to hosted CI.

The earlier stale GitHub potential merge was not used as the tested current-main tree. The candidate retains the intervening standalone runtime release changes. Source fix only: existing published package bytes are unchanged. Normal merge and current protection checks apply.

@LauraGPT
LauraGPT merged commit a935a87 into modelscope:main Nov 5, 2026
7 checks passed
LauraGPT added a commit that referenced this pull request Nov 5, 2026
Deliver per-call VAD merge length (#3841) and per-frame dynamic silence scheduling (#3833).

Signed-off-by: LauraGPT <zhifu.gzf@alibaba-inc.com>
@LauraGPT LauraGPT mentioned this pull request Nov 5, 2026
LauraGPT added a commit that referenced this pull request Nov 5, 2026
Deliver tested VAD merge-length and dynamic-silence fixes (#3841, #3833).

Signed-off-by: LauraGPT <zhifu.gzf@alibaba-inc.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants